<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<html>
<head>
    <meta charset="UTF-8">

    <!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">

    <!-- 可选的 Bootstrap 主题文件（一般不用引入） -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap-theme.min.css" integrity="sha384-6pzBo3FDv/PJ8r2KRkGHifhEocL+1X2rVCTTkUfGk7/0pbek5mMa1upzvWbrUbOZ" crossorigin="anonymous">

    <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous"></script>

    <%
        pageContext.setAttribute("APP_PATH",request.getContextPath());
    %>
    <meta charset="UTF-8">

    <link rel="stylesheet" href="${APP_PATH}/static/css/main.css">
    <link rel="stylesheet" href="${APP_PATH}/static/lib/font-awesome/css/font-awesome.css">
</head>
<body>

<!--
    作者：李明岢
    时间：2021-10-11
    描述：巨幕
-->

<div class="jumbotron" align="center">
    <h1>帅哥你好，请对这里的用户进行管理</h1>
</div>

<div class="actions">
    <div>
        <shiro:hasPermission name="sys:user:add">
            <a class="btn btn-primary" href="${APP_PATH}/shiro/user/useradd">添加用户信息</a>
        </shiro:hasPermission>

    </div>
</div>
<div class="actions" style="right: auto">
    <shiro:hasPermission name="sys:user:select">
        <form method="post" action="${APP_PATH}/shiro/user/selectbyname">
            <input type="text"  name="username" placeholder="输入关键字查询" >
            <input type="submit" id="select" value="搜索">
        </form>
    </shiro:hasPermission>
</div>

<!--
    作者：offline
    时间：2021-10-11
    描述：表格
-->
<table class="list">
    <tr>
        <th>id</th>
        <th>用户名</th>
        <th>密码</th>
        <th>年龄</th>
        <th>手机号码</th>
        <th>状态</th>
        <th>角色名</th>
        <th>角色详情</th>
        <th>操作</th>
    </tr>
    <c:forEach var="user" items="${pageInfo.list}" varStatus="status">

        <tr>
            <td>${user.uId}</td>
            <td>${user.uUsername}</td>
            <td>${user.uPassword}</td>
            <td>${user.uAge}</td>
            <td>${user.uTel}</td>
            <c:if test="${user.uStatus==1}">
                <td>在职</td>
            </c:if>
            <c:if test="${user.uStatus==0}">
                <td>离职</td>
            </c:if>
            <td>${user.role.rName}</td>
            <td>${user.role.rDesc}</td>
            <td>
                <shiro:hasPermission name="sys:user:delete">
                    <button onclick="delbyname(${user.uId})">删除</button>
                </shiro:hasPermission>
             <shiro:hasPermission name="sys:user:update">
                 <button onclick="edit1(${user.uId})">编辑</button>
             </shiro:hasPermission>

            </td>
        </tr>


    </c:forEach>
</table>


<!--
    作者：offline
    时间：2021-10-11
    描述：分页
-->

<div class="pager-info">
    <div>共有 ${pageInfo.total} 条记录，第 ${pageInfo.pageNum}/${pageInfo.pages} 页 </div>
    <div>
        <ul class="pagination">
            <li class="paginate_button previous disabled }">
                <a href="${APP_PATH}/shiro/user/menus?pn=${pageInfo.hasPreviousPage ? pageInfo.prePage:1}">上一页</a>
            </li>
            <c:forEach begin="1" end="${pageInfo.pages}"  var="page">
                <li class="${pageInfo.pageNum == page?'paginate_button active':''}"><a href="${APP_PATH}/shiro/user/menus?pn=${page}">${page}</a></li>
            </c:forEach>
            <li class="paginate_button next disabled">
                <a href="${APP_PATH}/shiro/user/menus?pn=${pageInfo.hasNextPage ? pageInfo.nextPage:pageInfo.pages}">下一页</a>
            </li>
        </ul>
    </div>
</div>
</body>
<script type="text/javascript">
function edit1(id){
    window.location.href="${APP_PATH}/shiro/user/useredit?uId="+id;
}

function delbyname(uId){
    window.location.href="${APP_PATH}/shiro/user/delbyId?uId="+uId;
}
</script>


</html>

